package com.example.cloudpracticeplatform.controller;
import com.example.cloudpracticeplatform.entity.Statistics;
import com.example.cloudpracticeplatform.service.StatisticsService;
import com.example.cloudpracticeplatform.common.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@RestController
@RequestMapping("/api/statistics")
@CrossOrigin
public class StatisticsController {
    @Autowired
    private StatisticsService statisticsService;

    // 获取基础统计数据
    @GetMapping("/basic")
    public Response<Statistics> getBasicStatistics() {
        return Response.success(statisticsService.getBasicStatistics());
    }

    // 获取教师相关统计数据
    @GetMapping("/teacher/{teacherId}")
    public Response<Statistics> getTeacherStatistics(@PathVariable Long teacherId) {
        return Response.success(statisticsService.getTeacherStatistics(teacherId));
    }

    // 获取课程难度等级分布
    @GetMapping("/course/levels")
    public Response<List<Statistics>> getCourseLevelStatistics() {
        return Response.success(statisticsService.getCourseLevelStatistics());
    }

    // 获取课程时长统计
    @GetMapping("/course/durations")
    public Response<Statistics> getCourseDurationStatistics() {
        return Response.success(statisticsService.getCourseDurationStatistics());
    }

    // 获取单门课程的选课人数
    @GetMapping("/course/enrollments/{courseId}")
    public Response<Statistics> getCourseEnrollmentsStatistics(@PathVariable Long courseId) {
        return Response.success(statisticsService.getCourseEnrollmentsStatistics(courseId));
    }

    // 获取选课趋势统计（周/月）
    @GetMapping("/enrollments/trend")
    public Response<Statistics> getEnrollmentTrendStatistics() {
        return Response.success(statisticsService.getEnrollmentTrendStatistics());
    }

    // 获取容器状态统计
    @GetMapping("/containers/status")
    public Response<List<Statistics>> getContainerStatusStatistics() {
        return Response.success(statisticsService.getContainerStatusStatistics());
    }

    // 获取容器使用时长统计
    @GetMapping("/containers/duration")
    public Response<Statistics> getContainerDurationStatistics() {
        return Response.success(statisticsService.getContainerDurationStatistics());
    }
}